<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<div class="line-big">
	<div class="xl12">
		<div class="panel border-back" id="write_goods_info_div">
			<div class="panel-foot bg-yellow-light border-back">
				<div class="line-big">
					<div class="xl3 text-center border-small border-right border-blue">商品信息</div>
					<div class="xl2 text-center border-small border-right border-blue">留言内容</div>
					<div class="xl1 text-center border-small border-right border-blue">留言时间</div>
					<div class="xl2 text-center border-small border-right border-blue">回复内容</div>
					<div class="xl1 text-center border-small border-right border-blue">回复时间</div>
					<div class="xl1 text-center border-small border-right border-blue">回复卖家</div>
					<div class="xl1 text-center border-small border-right border-blue">处理状态</div>
					<div class="xl1 text-center">操作</div>
				</div>
			</div>
			<ul class="list-group list-striped">
				<c:forEach items="${buyerMessageViewList}" var="bmv">
					<li id="c_${bmv.buyerMessage.buyerMessageId }">
						<div class="line-big">
							<div class="xl3 text-left">
								<h4 title="${bmv.goods.goodsName }">
									<strong>${bmv.goods.goodsName }</strong>
								</h4>
								<h6>
									<p>${bmv.goods.goodsTips }<button class="button button-little bg-blue dialogs see_goods_detail_button" data-toggle="click" data-target="#see_goods_detail" data-mask="1" data-width="960px"
											data-url="shop/show_goods_detail?commonStr=${bmv.goods.goodsId }">
											<span class="icon-eye"></span> 查看详情
										</button>
									</p>
								</h6>

							</div>
							<div class="xl2 text-left">${bmv.buyerMessage.buyerMessageContent }</div>
							<div class="xl1 text-center">
								<h6>
									<fmt:formatDate value="${bmv.buyerMessage.buyerMessageTime }" pattern="yyyy-MM-dd HH:mm" />
								</h6>
							</div>
							<div class="xl2 text-left">
								<c:if test="${bmv.buyerMessage.buyerMessageReply!=null }">
								${bmv.buyerMessage.buyerMessageReply}
								</c:if>
							</div>
							<div class="xl1 text-center">
								<c:if test="${bmv.buyerMessage.buyerMessageReplyTime!=null }">
									<h6>
										<fmt:formatDate value="${bmv.buyerMessage.buyerMessageReplyTime }" pattern="yyyy-MM-dd HH:mm" />
									</h6>
								</c:if>
							</div>
							<div class="xl1 text-center">
								<c:if test="${bmv.buyerMessage.buyerMessageReplySellerId!=null }">
									<h6>${bmv.buyerMessage.buyerMessageReplySellerId }</h6>
								</c:if>
							</div>
							<div class="xl1 text-center">
								<c:choose>
									<c:when test="${bmv.buyerMessage.buyerMessageStatus=='待处理' }">
										<span class="badge bg-red">待处理</span>
									</c:when>
									<c:when test="${bmv.buyerMessage.buyerMessageStatus=='已回复' }">
										<span class="badge bg-blue">已回复</span>
									</c:when>
									<c:when test="${bmv.buyerMessage.buyerMessageStatus=='已忽略' }">
										<span class="badge">已忽略</span>
									</c:when>
								</c:choose>
							</div>
							<div class="xl1 text-center">
								<c:choose>
									<c:when test="${bmv.buyerMessage.buyerMessageStatus=='待处理' }">
										<button class="reply_message_button button button-little bg-blue" data-id="${bmv.buyerMessage.buyerMessageId }">
											<span class="icon-pencil"></span> 回复留言
										</button>
										<button class="forget_message_button button button-little bg-red G-MarginTop5" data-id="${bmv.buyerMessage.buyerMessageId }" data-li="#c_${bmv.buyerMessage.buyerMessageId }">
											<span class="icon-eye-slash"></span> 忽略
										</button>
									</c:when>
									<c:when test="${bmv.buyerMessage.buyerMessageStatus=='已回复' }">
									</c:when>
									<c:when test="${bmv.buyerMessage.buyerMessageStatus=='已忽略' }">
									</c:when>
								</c:choose>

							</div>
						</div>
					</li>
				</c:forEach>
			</ul>
			<div class="panel-foot bg-white border-back" id="message_list_pages" data-url="pages_button" data-index="${page.currentIndex}" data-pages="${page.totalPages}" data-href="shop/show_message_info_list?s=${param.s }&i="></div>
		</div>
	</div>
</div>
<div class="clearfix G-MarginTop100"></div>

<div style="display: none;" id="goodsTypeJson">${goodsTypeJson }</div>
<div style="display: none;" id="k" data-value="${param.k }"></div>
<div style="display: none;" id="tid" data-value="${param.tid }"></div>
<div id="see_goods_detail"></div>
<script type="text/javascript" src="js/pintuer.js"></script>
<script type="text/javascript">
	$(function()
	{
		$(".reply_message_button").click(function()
		{
			$("#admin_div").load("shop/reply_buyer_message?id=" + $(this).attr("data-id"), {}, function()
			{

			});
		});

		$("#message_list_pages").load($("#message_list_pages").attr("data-url"),
		{
			"page.currentIndex" : $("#message_list_pages").attr("data-index"),
			"page.totalPages" : $("#message_list_pages").attr("data-pages"),
			"page.href" : $("#message_list_pages").attr("data-href")
		}, function()
		{
		});
		$("#message_list_pages").on("click", "button[data-url]", function()
		{
			$("#admin_div").load(encodeURI($(this).attr("data-url")), {}, function()
			{
			});
		});

		$(".forget_message_button").each(function()
		{
			$(this).click(function()
			{
				if (confirm("确认忽略此留言吗?") == false)
				{
					return false;
				}
				var ids = "";
				ids = $(this).attr("data-id");
				var obj = $(this);

				obj.attr("disabled", "disabled");
				$.post("admin/m_forget_message_do",
				{
					"id" : ids
				}, function(json)
				{
					if (json.success == false)
					{
						alert(json.info);
						obj.removeAttr("disabled");
					}
					else
					{
						obj.removeAttr("disabled");
						$(obj.attr("data-li")).remove();
					}
				},
				//返回类型
				"json");
			});
		});

	});
</script>